package com.xxl.sso.server.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 缓存操作线程池配置
 */
@EnableAsync
@Configuration
public class ExecutorConfig {

    @Bean
    public ThreadPoolExecutor executor() {
        return new ThreadPoolExecutor(10,
                100,
                60,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(500),
                new ThreadPoolExecutor.DiscardPolicy());
    }
}
